package com.two.inventory.service.impl;

import java.util.List;

import com.two.commodityorder.dao.CommodityDao;
import com.two.commodityorder.dao.impl.CommodityDaoImpl;
import com.two.commodityorder.model.Commodity;
import com.two.inventory.dao.InventoryDao;
import com.two.inventory.dao.impl.InventoryDaoImpl;
import com.two.inventory.model.Inventory;
import com.two.inventory.service.InventoryService;
import com.two.user.dao.UserDao;
import com.two.user.dao.impl.UserDaoImpl;
import com.two.user.model.User;


public class InventoryServiceImpl implements InventoryService{
	/**查询所有库存服务层实现*/
	@Override
	public List<Inventory> selectAll() {
		InventoryDao dao = new InventoryDaoImpl();
		return dao.selectAll();
	}

	/**根据id查询库存*/
	@Override
	
	public Inventory selectById(String id) {
		InventoryDao dao = new InventoryDaoImpl();
		int i = Integer.valueOf(id);
		return dao.selectById(i);
		
	}
	
	/**添加库存服务层实现*/
	@Override
	public boolean addInventory(String id, String inventoryname, String price, String number) {
		InventoryDao dao = new InventoryDaoImpl();
		int i = Integer.valueOf(id);
		int j = Integer.valueOf(number);
		int n = dao.addInventory(i, inventoryname,price, j);
		return n>0;
	}
	/**更新库存服务层实现*/
	@Override
	public boolean updateInventory(String id, String inventoryname, String price, String number) {
		InventoryDao dao = new InventoryDaoImpl();

		int i = Integer.valueOf(id);
		int j = Integer.valueOf(number);
		int n = dao.updateInventory(i,inventoryname,price, j);
		return n>0;
	}
	/**删除库存服务层实现*/
	@Override
	public boolean deleteInventory(String id) {
		InventoryDao dao = new InventoryDaoImpl();
		int i = Integer.valueOf(id);
		int n = dao.deleteInventory(i);
		return n>0;
	}

	


}